using System;
using FU.Capstones.IMS.Web.Common;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;

namespace FU.Capstones.IMS.Web.Silverlight.Models
{
    public class RoleListModel : ModelBase
    {
        public RoleListModel()
        {
            client.DeleteRoleCompleted += DoDeleteRoleCompleted;
            client.UndoDeleteRoleCompleted += DoUndoDeleteRoleCompleted;
            client.GetRoleCollectionCompleted += DoGetRoleCollectionCompleted;
            client.GetSingleRoleCompleted += DoGetSingleRoleCompleted;
            client.SearchRoleCompleted += DoSearchRoleCompleted;
            client.UpdateRoleCompleted += DoUpdateRoleCompleted;
            client.InsertRoleCompleted += DoInsertRoleCompleted;
        }

        #region InsertRole

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertRoleCompleted;

        public int InsertRoleAsync(Role data)
        {
            client.InsertRoleAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoInsertRoleCompleted(object sender, SingleFeedbackCompletedEventArgs<int> e)
        {
            if (InsertRoleCompleted != null)
            {
                InsertRoleCompleted(sender, e);
            }
        }

        #endregion

        #region UpdateRole

        public event EventHandler<FeedbackCompletedEventArgs> UpdateRoleCompleted;

        public int UpdateRoleAsync(Role data)
        {
            client.UpdateRoleAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoUpdateRoleCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (UpdateRoleCompleted != null)
            {
                UpdateRoleCompleted(sender, e);
            }
        }

        #endregion

        #region SearchRole

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Role>> SearhRoleCompleted;

        public int SearchRoleAsync(Role criteria)
        {
            client.SearchRoleAsync(criteria);
            return WebConstants.MagicNumer;
        }

        void DoSearchRoleCompleted(object sender, CollectionFeedbackCompletedEventArgs<Role> e)
        {
            if (SearhRoleCompleted != null)
            {
                SearhRoleCompleted(sender, e);
            }
        }

        #endregion

        #region GetRoleCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Role>> GetRoleCollectionCompleted;

        public int GetRoleCollectionAsync(bool isShowAll)
        {
            client.GetRoleCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        void DoGetRoleCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Role> e)
        {
            if (GetRoleCollectionCompleted != null)
            {
                GetRoleCollectionCompleted(sender, e);
            }
        }

        #endregion

        #region DeleteRole

        public event EventHandler<FeedbackCompletedEventArgs> DeleteRoleCompleted;

        public int DeleteRoleAsync(int data)
        {
            client.DeleteRoleAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoDeleteRoleCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (DeleteRoleCompleted != null)
            {
                DeleteRoleCompleted(sender, e);
            }
        }

        #endregion

        #region DeleteRole

        public event EventHandler<FeedbackCompletedEventArgs> UndoDeleteRoleCompleted;

        public int UndoDeleteRoleAsync(int data)
        {
            client.UndoDeleteRoleAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoUndoDeleteRoleCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (UndoDeleteRoleCompleted != null)
            {
                UndoDeleteRoleCompleted(sender, e);
            }
        }

        #endregion

        #region GetSingleRole

        public event EventHandler<SingleFeedbackCompletedEventArgs<Role>> GetSingleRoleCompleted;

        public int GetSingleRoleAsync(int objID)
        {
            client.GetSingleRoleAsync(objID);
            return WebConstants.MagicNumer;
        }

        void DoGetSingleRoleCompleted(object sender, SingleFeedbackCompletedEventArgs<Role> e)
        {
            if (GetSingleRoleCompleted != null)
            {
                GetSingleRoleCompleted(sender, e);
            }
        }

        #endregion
    }
}